#include "webglk.h"

unsigned char glk_char_to_lower(unsigned char ch)
{
	if (ch>='A' && ch<='Z') return ch|0x20;
	return ch;
}
unsigned char glk_char_to_upper(unsigned char ch)
{
	if (ch>='a' && ch<='z') return ch&~0x20;
	return ch;
}

/*
we need to add arrow key ability to charinput, and include it in the gestalt
*/
glui32 glk_gestalt(glui32 sel,glui32 val)
{
	switch (sel)
	{
		case gestalt_Version: return (val==0)?0x00000700:0;
		case gestalt_CharInput: return (val>=' ' && val<='~');
		case gestalt_LineInput: return (val>=' ' && val<='~');
		case gestalt_CharOutput: return 1;
		case gestalt_Timer: return (val==0);
		case gestalt_Graphics: return (val==0);
		case gestalt_DrawImage: return (val==wintype_TextBuffer || val==wintype_Graphics);
		case gestalt_Hyperlinks: return (val==0);
		case gestalt_HyperlinkInput: return (val==wintype_TextBuffer || val==wintype_TextGrid);
		case gestalt_GraphicsTransparency: return 1;
		case gestalt_Unicode: return (val==0);
	}
	return 0;
}
